package com.yc.zyz.mapper;

import com.yc.zyz.entity.Task;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.zyz.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ly
 * @since 2024-07-28
 */
public interface TaskMapper extends BaseMapper<Task> {

    @Select("select * from task where id=#{id}")
    @Results(id="rm1",
    value={
            @Result(column = "id", property = "id", id = true),
            @Result(column = "uid", property = "uid"),
            @Result(column = "uid", property = "user",
            one = @One(select = "com.yc.zyz.mapper.UserMapper.selectById")),
            @Result(column = "id", property = "joins",
            many = @Many(select = "selectUserByTid")),
    })
    Task findById(String id);

    @Select("select * from user a join joins b on a.id=b.uid where b.tid=#{tid}")
    List<User> selectUserByTid(int tid);

}
